#include <iostream>
#include "CvHeader.h"
using namespace std;

void testPixelAndImage();
void testVideo();
int main(int argc, char* argv[])
{   
  /* put your testing code here */
	
   //testPixelAndImage()
	testVideo();
	return 0;
}
void testVideo2(){
	CvVideo *pv1 = new CvVideo();
	pv1->readFile("test.avi");

	CvVideo *pv2 = pv1->fade_in("test_fin.avi", 1);
	CvVideo *pv3 = pv1->fade_out("test_fout.avi", 1);
	CvVideo *pv35 = pv2->join(pv3, "test_f.avi");
	CvVideo *pv4 = pv35 ->zoom(2, 2, "test_zoom.avi");
	CvVideo *pv5 = pv4->cropVideo(100, 100, 180, 180, "test_crop.avi");
	CvVideo *pv6 = pv5->resize(200, 50, "test_resize.avi");

}
void testVideo1(){
	CvVideo *pv1 = new CvVideo();
	pv1->readFile("test.avi");
	CvVideo *pv2 = pv1->copy("test.copy.avi");

	CvImage *i1 = new CvImage();
	i1->readFile("lena.jpg");
	CvVideo vLena;
	vLena.createFromImage(i1, 2, 24, "lena.avi");

	CvImage *frame1 = pv2->grabFrameByFrame(1);
	

	CvImage *frame2 = pv2->grabFrameByTime(1.5);

	frame1->saveFile("capture1.jpg");
	frame2->saveFile("capture2.jpg");

	printf("%d %d %d %lf %lf\n", vLena.width(), vLena.height(), vLena.frameCount(),
		vLena.length(), vLena.frameRate());
}
void testVideo(){
	//testVideo1();
	testVideo2();
}
void testPixelAndImage(){
	CvPixel p1(1,2,3);
	
	CvImage *i1 = new CvImage();
	i1->readFile("lena.jpg");
	CvImage *i2 = i1->resize_image(i1->width()/2,i1->height()/3);
	i2->saveFile("lena.copy.jpg");

	CvPixel p2 = i2->grabPixel(0, 0);
	printf("%s\n",p1.toString());
	printf("%s\n",p2.toString());
}
